#define DEBUG
#include <cstdio>
#include <bitset>

using namespace std;

const int maxn=10000;

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static bitset<maxn> x, y, u, v;
  int t;
  scanf("%d", &t);
  for (int ti=1; ti<=t; ti++) {
    x.set(), y.set();
    static int a[maxn+1], p[maxn+1];
    int n;
    scanf("%d", &n);
    for (int i=1; i<=n; i++) {
      scanf("%d", a+i);
      p[a[i]] = i;
    }

    bool flag=false;
    for (int i=1; i<=n; i++) {
      x[a[i]-1] = 0;
      y[n-a[i]] = 0;
      u = x<<(maxn-a[i]+1)>>(maxn-a[i]+1), v = y<<(maxn-n+a[i])>>(maxn-n+a[i]);
      int t=a[i]<n-a[i]+1 ? a[i] : n-a[i]+1;
      if (((u>>(a[i]-t))^(v>>(n-a[i]-t+1))).any()) {
	flag = true;
	break;
      }
    }
    printf(flag ? "Y\n" : "N\n");
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
